package com.prs.crm.domain.hr;

import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

import com.prs.crm.annotation.DomainRelation;
import com.prs.crm.annotation.DomainRelations;
import com.prs.crm.domain.Attachment;
import com.prs.crm.domain.BaseEntity;

@Entity
@Table(name="hr_leave")
@DomainRelations(relations={@DomainRelation(rely="com.prs.crm.domain.hr.LeaveAudit",property="leave")})
public class Leave extends BaseEntity{
	
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	@ManyToOne
	private LeaveType type;
	private Date beginTime;
	private Date endTime;
	//private String attach;
	@Lob
	private String content;
	@OrderBy
	private String state;
	@OneToMany(fetch=FetchType.LAZY,mappedBy="leave")
	private Set<LeaveAudit> audits;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@Cascade({org.hibernate.annotations.CascadeType.ALL,org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
	private Attachment attach;
	@Column(name="leave_file")
	private String leave_file;
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public LeaveType getType() {
		return type;
	}
	public void setType(LeaveType type) {
		this.type = type;
	}
	public Date getBeginTime() {
		return beginTime;
	}
	public void setBeginTime(Date beginTime) {
		this.beginTime = beginTime;
	}
	public Date getEndTime() {
		return endTime;
	}
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
/*	public String getAttach() {
		return attach;
	}
	public void setAttach(String attach) {
		this.attach = attach;
	}*/
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public void setState(String state) {
		this.state = state;
	}
	public String getState() {
		return state;
	}
	public void setAudits(Set<LeaveAudit> audits) {
		this.audits = audits;
	}
	public Set<LeaveAudit> getAudits() {
		return audits;
	}
	public void setAttach(Attachment attach) {
		this.attach = attach;
	}
	public Attachment getAttach() {
		return attach;
	}
	public String getLeave_file() {
		return leave_file;
	}
	public void setLeave_file(String leaveFile) {
		leave_file = leaveFile;
	}
	
}
